<template>
	<view class="index">
		<nav-bar title="免费设计" isBack></nav-bar>
		<!-- 顶部 -->
		<view class="topcont">
			<view class="topinput">
				<view class="i_top">
					<view class="i_tCan" slot="center">
						<view>

						</view>
						<view class="i_tInput">
							<view class="i_tiIcon iconfont icon-search"></view>
							<input type="text" confirm-type="search" v-model="searchVal" @confirm="searchData"
								placeholder="搜索您感兴趣的内容" placeholder-class="col-ccc" />
						</view>
						<view class="i_tBtn">
							<view class="i_tbIcon" @click="gitchat()"><text class="iconfont iconhuaban110"></text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="i_three">
				<view class="i_tSwiper" style="height:600rpx">
					<swiper autoplay interval="4200" duration="300" @change='threeBannerChange'>
						<swiper-item v-for="(item,index) in banner" :key="index">
							<view class="i_tCont">
								<image :src="item.img" mode="widthFix"></image>
							</view>
						</swiper-item>
					</swiper>
					<view class="i_tDots">
						<view class="i_tDot" v-for="(item,index) in banner" :key="index"
							:class="{'active': index == threeIndex}">
							<view class="i_tIcon"></view>
						</view>
					</view>
				</view>
			</view>

		</view>

		<view class="i_bTitle">立即申请免费设计</view>
		<view class="cardinput">
			<view class="card">
				<input class="price_input" style="padding-right: 50rpx;" placeholder="请输入您的姓名(必填)" type="text"
					v-model="name"></input>
			</view>
			<view class="card">
				<input class="price_input" style="padding-right: 50rpx;" placeholder="请输入您的手机号码(必填)" type="number"
					v-model="phone"></input>
			</view>
			<view @click="submitAddress" class="bnts">立即申请</view>
		</view>
		<view class="i_bTitle">免费户型设计</view>
		<view class="imgs">
			<image src="https://cos.ryz1620.com/liankun/static/free3.jpg" mode="widthFix"></image>
		</view>
		<!-- 设计师推荐 -->
		<view class="i_design">
			<view class="i_dOper"><text>更多</text><view class="i_doIcon"><view class="iconfont icon-more"></view></view></view>
			<view class="i_dTitle"><text>设计大咖1对1服务</text></view>
			<view class="i_dList">
				<view class="i_dItem" v-for="(item,index) in supportlist" :key="index" @click="navTo('/pages_design/pages/design/personal/personal?designerId=' + item.id)">
					<view class="i_dUser">
						<view class="i_dHead"><image :src="item.avatar.path"></image></view>
						<view class="of-hidden">
							<view class="i_dFee"><text class="ft-bold fs-28">{{item.end_offer}}</text>元/m²</view>
							<view class="of-hidden">
								<view class="i_dName">{{item.name}}</view>
								<view class="i_dRemark">从业 {{item.employ_year}}年 | 方案 {{item.case_num}}</view>
							</view>
							<view class="i_dTags">
								<view class="i_dTag" v-for="(items,indexs) in item.design_style" :key="indexs">{{items.name}}</view>
							</view>
						</view>
					</view>
					<view class="i_dImage"><image :src="item.back_thumb_url.path"></image></view>
				</view>
				
			</view>
		</view>
		<view class="i_bTitle">海量装修风格</view>
		<view class="imgs" style="padding: 0 30rpx 50rpx 30rpx;">
			<image src="https://cos.ryz1620.com/liankun/static/free7.jpg" mode="widthFix"></image>
		</view>
		<view class="imgs" style="padding: 0 30rpx 50rpx 30rpx;">
			<image src="https://cos.ryz1620.com/liankun/static/free8.jpg" mode="widthFix"></image>
		</view>
		<view class="imgs" style="padding: 0 30rpx 50rpx 30rpx;">
			<image src="https://cos.ryz1620.com/liankun/static/free9.png" mode="widthFix"></image>
		</view>


	</view>
</template>

<script>
	import navBar from "@/components/navBar/navBar.vue"
	import service_mall from '@/service/mall.js'
	import service_design from '@/service/design'
	import URL from '@/config/url.js'

	export default {
		components: {
			navBar
		},

		data() {
			return {
				banner: [],
				threeIndex: 0,
				threeIndexs: 0,
				bannerlist: [],
				userId: "",
				searchVal: '',
				getRecommendList: [],
				supportlist: [],
				name:'',
				phone:''
                
			}
		},
		onLoad(params) {
			this.$utils.getUrl()
			this.banners()
			this.support()
			this.userId = uni.getStorageSync('userId')
			let token = uni.getStorageSync('token')
			if(params.share_uid){
				let shareuId= params.share_uid
				this.$store.commit('index/SET_shareuId', shareuId)
				if(token && shareuId){
					service_mall.getPromoter({share_uid:shareuId})
						.then(res => {
					})
				}
			}
		},
		onShareAppMessage(res) {
			let that = this
			if (res.from === 'button') {}
			return {
				title: '融易装',
				path: '/pages_now/pages/now/freedesgin/index?share_uid=' + this.userId,
				success: function(res) {}
			}
		},
		methods: {
			// 3D-轮播图切换
			threeBannerChange(e) {
				this.threeIndex = e.detail.current
			},
			// 3D-轮播图切换
			threeBannerChanges(e) {
				this.threeIndexs = e.detail.current
			},
			searchData() {
				uni.navigateTo({
					url: '/pages_mall/pages/mall/goods/list?keyword=' + this.searchVal
				})
			},
			navTo(url) {
				uni.navigateTo({
					url
				})
			},
			toONEshop(url) {
				uni.navigateTo({
					url
				});
			},
			// 推荐设计师
			support(){
				service_design.support({
					identity:2
				}).then(res => {
					if (res.code == 1) {
						this.supportlist = res.data
					}
				});
			},
			isPhone(t) {
			        return /^1[3|4|5|6|7|8|9]\d{9}$/.test(t);
			 },
			submitAddress(){
				if (!this.name) return uni.showToast({title: "请输入姓名", icon: "none"});
				if (!this.phone) return uni.showToast({title: "请填写号码", icon: "none"});
				if (!this.isPhone(this.phone)) return uni.showToast({title: "号码格式不对", icon: "none"});
				service_design.DesignApply({
					name:this.name,
					phone:this.phone,
				}).then(res => {
					if (res.code == 1) {
						uni.showModal({
						    title: '提示',
						    content: '恭喜您申请成功!请稍后我们的设计师将会对您进行一对一的服务！感谢您对我们的支持',
							confirmText:'确定',
							showCancel:false,
						    success: function (res) { 
						    }
						});
					}else{
						uni.showToast({title: res.msg, icon: "none"});
					}
				});
			},
			// 客服
			gitchat() {
				let token = uni.getStorageSync('token')
				if (token) {
					uni.navigateTo({
						url: "/pages_customer/pages/index?partner_type=root&partner_id=0"
					})
				} else {
					uni.showModal({
						title: "提示！",
						content: "请先登录！",
						success: function(s) {
							if (s.confirm) {
								uni.navigateTo({
									url: '/pages_login/pages/login/login/index',
								});
							}
						}
					});
				}
			},
			// banner
			banners() {
				service_mall.index_getBanner({
					type: 24
				}).then(res => {
					if (res.code == 1) {
						this.banner = res.data
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.index {
		width: 100vw;
		min-height: 100vh;
		background: #fff;
		display: flex;
		flex-flow: column;
	}

	.topcont {
		position: relative;
	}

	.topinput {
		position: absolute;
		top: 20rpx;
		width: 100%;
		left: 0;
		z-index: 99;
	}

	.kficon {
		position: absolute;
		bottom: 100rpx;
		width: 220rpx;
		height: 60rpx;
		line-height: 60rpx;
		color: #fff;
		text-align: center;
		border-radius: 50rpx;
		background: #ffbe00;
		left: 50%;
		margin-left: -90rpx;
	}

	.i_top {
		margin-top: 20rpx;
		padding-left: 32rpx;
		padding-right: 120rpx;
		position: relative;

		.i_tCan {
			width: 100%;
		}

		.i_tBtn {
			width: 100rpx;
			display: flex;
			flex-flow: column;
			justify-content: center;
			align-items: center;
			position: absolute;
			right: 10rpx;
			top: 0;
		}

		.i_tbIcon {
			width: 60rpx;
			height: 60rpx;
			line-height: 60rpx;
			text-align: center;
			color: #fff;
			font-size: 42rpx;
		}

		.i_tbTxt {
			height: 28rpx;
			line-height: 28rpx;
			font-size: 20rpx;
			margin-top: 4rpx;
		}

		.i_tInput {
			height: 60rpx;
			border-radius: 36rpx;
			background: rgba(255, 255, 255, 0.5);
			position: relative;
			overflow: hidden;

			&>input {
				width: 100%;
				height: 100%;
				font-size: 24rpx;
				padding: 0 24rpx 0 72rpx;
			}
		}

		.i_tiIcon {
			width: 32rpx;
			height: 32rpx;
			line-height: 32rpx;
			color: #ccc;
			font-size: 32rpx;
			margin-top: -16rpx;
			position: absolute;
			top: 50%;
			left: 28rpx;
		}
	}

	.i_tSwiper {
		position: relative;
	}

	.i_tDots {
		width: 100%;
		position: absolute;
		bottom: 15rpx;
		left: 0;
		display: flex;
		justify-content: center;
	}

	.i_tDot {
		width: 50rpx;
		height: 6rpx;
		margin: 0 5rpx;

		&.active .i_tIcon {
			background: #ffd425;
		}

		.i_tIcon {
			width: 50rpx;
			height: 6rpx;
			background: rgba(255, 255, 255, .5);
		}
	}

	// 功能
	.i_fun {
		display: flex;
		padding: 30rpx;

		.i_fItem {
			flex: 1;
		}

		.i_fIcon {
			width: 60rpx;
			height: 60rpx;
			margin: 40rpx auto 0;
		}

		.i_fTxt {
			height: 34rpx;
			line-height: 34rpx;
			text-align: center;
			font-size: 24rpx;
			margin-top: 14rpx;
		}
	}

	.infodata {
		background: #fff;
		position: absolute;
		width: 100%;
		bottom: 0;
		left: 0;
		z-index: 99;
		border-radius: 20rpx 20rpx 0 0;
		padding: 30rpx 60rpx;

		.infoc {
			border: 1px #eb1d21 solid;
			height: 70rpx;
			line-height: 70rpx;
			display: flex;
			border-radius: 40rpx;

			.iconfont {
				display: flex;
				color: #eb1d21;
				font-size: 34rpx;
				width: 80rpx;
				justify-content: center;
			}

			.infocont {
				color: #eb1d21;
			}
		}
	}

	.btnicon {
		position: absolute;
		bottom: 100rpx;
		width: 100%;
		height: 60rpx;
		line-height: 60rpx;
		display: flex;
		justify-content: center;

		view {
			display: inline-block;
			background: rgba(255, 255, 255, 0.5);
			color: #fff;
			border-radius: 50rpx;
			padding: 0 30rpx;
			font-size: 28rpx;
			margin: 0 10rpx;
			text-shadow: 1px 1px 2px #333;
		}
	}

	.i_bOper {
		height: 62rpx;
		line-height: 62rpx;
		font-size: 24rpx;
		padding: 0 64rpx;
		margin-top: 30rpx;
		position: relative;
		float: right;
		padding-right: 30rpx;

		.i_boIcon {
			width: 32rpx;
			height: 32rpx;
			line-height: 32rpx;
			text-align: center;
			color: #6c6c6c;
			font-size: 30rpx;
			margin-top: 15rpx;
			float: right;
		}
	}

	.i_bTitle {
		height: 110rpx;
		line-height: 122rpx;
		font-size: 36rpx;
		font-weight: bold;
		padding-left: 32rpx;
	}

	// 设计师推荐
	.i_design {
		margin-top: 24rpx;

		.i_dOper {
			height: 62rpx;
			line-height: 62rpx;
			font-size: 24rpx;
			padding: 0 72rpx;
			margin-top: 30rpx;
			position: relative;
			float: right;

			.i_doIcon {
				width: 32rpx;
				height: 32rpx;
				margin-top: -16rpx;
				position: absolute;
				top: 50%;
				right: 32rpx;
			}
		}

		.i_tOper {
			height: 62rpx;
			line-height: 62rpx;
			font-size: 24rpx;
			padding: 0 64rpx;
			margin-top: 30rpx;
			position: relative;
			float: right;

			.i_toIcon {
				width: 32rpx;
				height: 32rpx;
				line-height: 32rpx;
				text-align: center;
				color: #6c6c6c;
				font-size: 32rpx;
				margin-top: -16rpx;
				position: absolute;
				top: 50%;
				right: 32rpx;
			}
		}

		.i_dTitle {
			height: 86rpx;
			line-height: 122rpx;
			font-size: 36rpx;
			font-weight: bold;
			padding-left: 32rpx;
		}

		.i_dList {
			width: 100%;
			padding: 28rpx 32rpx;
			overflow-x: auto;
			white-space: nowrap;

			&::-webkit-scrollbar {
				width: 0;
				height: 0;
				background-color: transparent;
			}
		}

		.i_dItem {
			width: 512rpx;
			height: 446rpx;
			margin-right: 24rpx;
			border-radius: 10rpx;
			background: #fff;
			box-shadow: 0 0 20rpx 0 rgba(0, 0, 0, .06);
			display: inline-block;

			&:nth-last-child(1) {
				margin: 0;
			}
		}

		.i_dUser {
			height: 164rpx;
			padding: 28rpx 28rpx 0;
		}

		.i_dHead {
			width: 64rpx;
			height: 64rpx;
			margin-right: 20rpx;
			border-radius: 50%;
			background: #f6f7fb;
			overflow: hidden;
			float: left;
		}

		.i_dFee {
			height: 44rpx;
			line-height: 44rpx;
			font-size: 20rpx;
			float: right;
		}

		.i_dName {
			height: 34rpx;
			line-height: 34rpx;
			font-size: 24rpx;
			font-weight: bold;
			margin-top: 2rpx;
		}

		.i_dRemark {
			height: 28rpx;
			line-height: 28rpx;
			font-size: 20rpx;
			color: #939393;
		}

		.i_dTags {
			margin-top: 8rpx;
		}

		.i_dTag {
			height: 36rpx;
			line-height: 36rpx;
			color: #a98f68;
			font-size: 20rpx;
			padding: 0 20rpx;
			margin-right: 8rpx;
			border-radius: 18rpx;
			background: #f9f6f3;
			display: inline-block;
		}

		.i_dImage {
			height: 254rpx;
			margin: 0 28rpx;
			border-radius: 8rpx;
			background: #f6f7fb;
			overflow: hidden;
		}
	}

	// 推荐案例
	.i_demo {
		margin-top: 24rpx;

		.i_dOper {
			height: 62rpx;
			line-height: 62rpx;
			font-size: 24rpx;
			padding: 0 64rpx;
			margin-top: 30rpx;
			position: relative;
			float: right;
			padding-right: 30rpx;

			.i_doIcon {
				width: 32rpx;
				height: 32rpx;
				line-height: 32rpx;
				text-align: center;
				color: #6c6c6c;
				font-size: 30rpx;
				margin-top: 15rpx;
				float: right;
			}
		}

		.i_dTitle {
			height: 110rpx;
			line-height: 122rpx;
			font-size: 36rpx;
			font-weight: bold;
			padding-left: 32rpx;
		}

		.i_dList {
			padding-left: 32rpx;
		}

		.i_dItem {
			width: 332rpx;
			height: 492rpx;
			margin-right: 22rpx;
			border-radius: 10rpx;
			overflow: hidden;
			display: inline-block;
		}

		.i_dImg {
			width: 100%;
			height: 300rpx;
			background: #f6f7fb;
			overflow: hidden;
		}

		.i_dTit {
			line-height: 36rpx;
			font-size: 24rpx;
			margin-top: 14rpx;
		}

		.i_dTags {
			margin-top: 12rpx;
		}

		.i_dTag {
			height: 36rpx;
			line-height: 36rpx;
			color: #a98f68;
			font-size: 20rpx;
			padding: 0 16rpx;
			margin-right: 8rpx;
			border-radius: 18rpx;
			background: #f9f6f3;
			display: inline-block;
		}

		.i_dUser {
			color: #939393;
			margin-top: 16rpx;
		}

		.i_dRemark {
			height: 36rpx;
			line-height: 36rpx;
			font-size: 20rpx;
			float: right;
		}

		.i_dHead {
			width: 36rpx;
			height: 36rpx;
			margin-right: 8rpx;
			border-radius: 50%;
			background: #f6f7fb;
			overflow: hidden;
			float: left;
		}

		.i_dName {
			height: 36rpx;
			line-height: 36rpx;
			font-size: 20rpx;
			overflow: hidden;
		}
	}

	.number {
		margin: 0 30rpx;
		background: #f0f0f0;
		border-radius: 10rpx;
		border: 1px #ccc solid;
	}

	.num-window {
		margin: 20rpx;
		height: 100rpx;
		border: 3rpx #333 solid;
		border-radius: 10rpx;
		background: #d3d3cb;

		view {
			width: 44rpx;
			height: 80rpx;
			float: right;
			margin-top: 10rpx;
			margin-right: 10rpx;
		}
	}

	.category {
		width: 70%;
		margin: 0 auto 20rpx;
		overflow: auto;

		span {
			width: 50%;
			float: left;
			text-align: center;
		}
	}

	.sing {
		padding: 0 20rpx;
		overflow: hidden;
	}

	.sing .cardlist {
		width: 50%;
		float: left;
	}

	.sing .cardlist .card {
		margin: 10rpx 10rpx;
	}
	.card {
		padding: 20rpx;
		display: flex;
		align-items: center;
		background-color: #fff;
		margin: 20rpx 30rpx;
		position: relative;
		border: 1px #dfdfdf solid;
		border-radius: 10rpx;
	}

	.card_name {
		flex-shrink: 0;
		padding-right: 60rpx;
	}

	.price_input {
		width: 100%;
		font-size: 28rpx;
		text-align: left;
	}

	picker {
		width: 100%;
		text-align: left;
	}

	.cell_c,
	.cell navigator {
		margin: 20rpx;
		padding: 20rpx 0 20rpx 20rpx;
		font-size: 32rpx;
		display: flex;
		align-items: center;
	}

	.cell_c picker {
		width: 100%;
		font-size: 28rpx;
		color: #888;
		line-height: 25px;
		padding-left: 54rpx;
		height: 46rpx;
		text-align: left;
	}

	.cell_name {
		flex-shrink: 0;
	}

	.line {
		padding: 10rpx;
		background-color: #f6f6f6;
	}

	.radio-cell {
		padding: 20rpx;
		font-size: 28rpx;
		color: #999;
	}

	.bnt {
		background-color: #C3AB7C;
		color: #fff;

	}

	.bnt,
	.bnt-delete {
		padding: 20rpx 20rpx;
		margin: 20rpx;
		text-align: center;
		border-radius: 40rpx;
	}

	.bnt-delete {
		background-color: #f6f6f6;
	}

	.cards {
		padding: 10rpx 0;
		background-color: #fff;
		margin: 20rpx 0;

		.card_name {
			padding: 0 30rpx;

			text {
				float: right;
				color: #999;
			}
		}

		textarea {
			width: 100%;
			margin: 20rpx 0;
			background: #f8f8f8;
			border-radius: 10rpx;
			padding: 20rpx;
			height: 240rpx;
		}
	}
.bnts{
	margin: 30rpx;
	height: 90rpx;
	text-align: center;
	line-height: 90rpx;
	background-color: #ff9000;
	color: #fff;
	box-shadow: 0 5rpx 10rpx #CCC;
	font-size: 30rpx;
	display: block;
	border-radius: 10rpx;
}
.ofer{
	text-align: right;
	margin-top: 30rpx;
	color: #909090;
	text{
		color: #f00;
	}
}	
</style>
